﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>书籍列表</title>
    <link rel="stylesheet" type="text/css" href="/manager/easyui/themes/default/easyui.css">
    <link rel="stylesheet" type="text/css" href="/manager/easyui/themes/icon.css">
    <script type="text/javascript" src="/manager/easyui/jquery.min.js"></script>
    <script type="text/javascript" src="/manager/easyui/jquery.easyui.min.js"></script>
	<script type="text/javascript">
	    //工具栏
	    var toolbar = [{
	        text: '修改',
	        iconCls: 'icon-edit',
	        handler: function () {  $('#dd').dialog('open');}
	    }, '-', {
	        text: '启用',
	        iconCls: 'icon-ok',
	        handler: function () { alert('ok') }
	    }, '-', {
	        text: '禁用',
	        iconCls: 'icon-cancel',
	        handler: function () { alert('cancel') }
	    }];
	   $(function(){
	       $('#booklist').datagrid({  
				title:'书籍列表',  
				iconCls:'icon-save',   
				// url:'json/datagrid_data1.json',
                url: "/manager/book/findAll",
				columns:[
				    [
					{field:'bookname',title:'名称',width:100,align:'center'},
					{field:'author',title:'作者',width:200,align:'center'},
					{field:'price',title:'单价',width:80,align:'center'},
					{field:'isbn',title:'ISBN',width:200,align:'center'},
					{field:'pressName',title:'出版社',width:200,align:'center'},
	                {field:'suppliers',title:'供货商',width:500,align:'center', formatter:function (val) {
	                    console.log("11111111");
	                    console.log(val);
	                    var lists = "";
	                    if (val != null){
                            for (let s of val){
                                console.log(s);
                                // 为什么会出现s为null的情况！
                                if (s != null){
                                    lists +=s.name+',';
                                }
                            }
                            return lists;
                        }else{
	                        return "";
                        }

                        }},
                    {field:'flag',title:'状态',width:100,align:'center', formatter:function (val) {
                            if (val == 1){
                                return "审核通过";
                            }else if(val == -1){
                                return "审核驳回";
                            }else {
                                return "审核中";
                            }
                        }}
				]
                ],
				toolbar: toolbar,  
				pagination: true,//表示在datagrid设置分页              
               	pageSize: 5,
				singleSelect:true,
                pageList: [5,10,20]
			});

		 //初始化查询栏
		 $("#submit_search").linkbutton({ iconCls: 'icon-search', plain: true })
            .click(function () {
                $('#booklist').datagrid({
                    queryParams:{
                        bookname: $("#bookname").val(),
                        isbn: $("#isbn").val(),
                        pressid:$("#search_press").combobox("getValue"),
                        supplierid:$("#search_supplier").combobox("getValue")
                    }
                });   //点击搜索
            });

          //初始化修改窗口  
         $('#dd').dialog({
			    title: 'My Dialog',
			    width: 700,
			    height: 500,
			    closed: true,
			    cache: false,
			    href: '',
			    modal: true,
			    iconCls: 'icon-save',
                buttons: [{
                    text:'提交',
                    iconCls:'icon-ok',
                    handler:function(){
                        alert('ok');
                    }
                },{
                    text:'关闭',
                    handler:function(){
                        alert('cancel');;
                    }
                }]
			});


         $('#search_press').combobox({
           method:'get',
           valueField:'id',
           textField:'name',
           panelHeight:'auto',
             url:"/manager/press/findAll",
         });

           $('#search_supplier').combobox({
               method:'get',
               valueField:'id',
               textField:'name',
               panelHeight:'auto',
               url:"/manager/supplier/findAll",
           });
	   });
	</script>
</head>
<body>
   <form name="searchform" method="post" action="" id ="searchform">
    <td width="70" height="30"><strong>书籍查询：</strong></td>
    <td height="30">
        <input id="bookname" type="text" name="keyword" size=20 placeholder="书籍名称"/>
        <input id="isbn" type="text" name="keyword" size=20 placeholder="ISBN"/>
        <select name="search_type" id="search_press" >
            <option id="-1">请选择出版社</option>
            <!--<option value="be_name" >出版社1</option>-->
            <!--<option value="be_intro">出版社2</option>-->
            <!--<option value="be_intro">出版社3</option>-->
        </select>
        <select name="search_type" id="search_supplier" >
            <option id="">请选择供应商</option>
            <!--<option value="be_name" >供应商1</option>-->
            <!--<option value="be_intro">供应商2</option>-->
            <!--<option value="be_intro">供应商3</option>-->
        </select>
        编辑推荐:<input type="checkbox" name="" value=""/>
        本周精选:<input type="checkbox" name="" value=""/>
    </td>
	<td>
	  <a id="submit_search">搜索</a>
	</td>
  </form>
  <table id="booklist"></table>
    <div id="dd">
           <div align="center" style="margin-top: 30px">
            <form id="ff" method="post">
            <div style="margin-bottom:20px">
                <input class="easyui-textbox" name="name" style="width:50%" data-options="label:'书籍名称:',required:true">
            </div>
            <div style="margin-bottom:20px">
                <input class="easyui-textbox" name="email" style="width:50%" data-options="label:'单价:',required:true,validType:'email'">
            </div>
            <div style="margin-bottom:20px">
                <input class="easyui-textbox" name="subject" style="width:50%" data-options="label:'团购价:',required:true">
            </div>
            <div style="margin-bottom:20px">
                <input class="easyui-textbox" name="message" style="width:50%;height:60px" data-options="label:'书籍简介:',multiline:true">
            </div>
             <div style="margin-bottom:20px">
                <input class="easyui-textbox" name="message" style="width:50%;height:60px" data-options="label:'作者简介:',multiline:true">
            </div>
             <div style="margin-bottom:20px">
               封面图片:&nbsp;&nbsp;&nbsp;&nbsp; <input  type="file"/>
            </div>
            <div style="margin-bottom:20px">
               编辑推荐:<input type="checkbox" name="" value=""/>
               本周精选:<input type="checkbox" name="" value=""/>
            </div>
            
        </form>
           </div>
    </div>
</body>
</html>